import { usePlayerStore } from "../../store/player";

export function useMove() {
    const { 
        movePlayerToUp,
        movePlayerToDown,
        movePlayerToLeft,
        movePlayerToRight
     } = usePlayerStore()
     function handleKeyup(e:KeyboardEvent) {
        switch(e.code) {
            case 'ArrowUp':
            movePlayerToUp()
            break;
            case 'ArrowDown':
            movePlayerToDown()
            break;
            case 'ArrowLeft':
            movePlayerToLeft()
            break;
            case 'ArrowRight':
            movePlayerToRight()
            break;
        }
    }
    window.addEventListener("keyup",handleKeyup)
}
